google.load("jquery", "1.3.2");
google.load("jqueryui", "1.7.2");
google.setOnLoadCallback(function() {
  initCommonAPI();
  $.geekGaTrackPage("UA-10316080-2");

	$('#main').css('-moz-user-select', 'none'); //禁止fx選取文字
	$('#main').get(0).onselectstart = function(){return false;}; //禁止IE選取文字
	
	$(".block").draggable({revert:true}); //放開區塊回復原位
	// all menu items
	$("#theMenu > div").droppable({
		accept: ".block",
		activeClass: 'droppable-active',
		hoverClass: 'droppable-hover',
		drop: function(ev, ui) {
			$(this).append($(ui.draggable));
      $('#report').text( '你取消了"' + $(ui.draggable).attr('id') + '"');
		}
	});
	// all user's orders
	$("#myOrder").droppable({
		accept: ".block",
		activeClass: 'droppable-active',
		hoverClass: 'droppable-hover',
		drop: function(ev, ui) {
			$(this).append($(ui.draggable));
      $('#report').text( '你點了"' + $(ui.draggable).attr('id') + '"');
		}
	});

  $("#theMenu").tabs();
});

function calc() {
	var element = $('#myOrder > .block');
	var val = '';
  var total_price = 0;
	for (var i = 0; i < element.length; i++) {
    var item  = $(element[i]);
    var quant = parseFloat(item.children('input:first').val());
    var price = parseFloat(item.attr('price'));
    var subTotal = quant * price;
    total_price += subTotal;
    val += '<div>' + element[i].id + ' * ' + quant + " = " + (quant * price) + '</div>';
	}
  $('#report').html('您選擇的訂單是：<p>' + val 
      + '<div> 總價:' + total_price + '</div>');
}
function sendOrder() {
  alert($("#report").text());
}
